//
//  FireBaseManager.swift
//  DaRings
//
//  Created by 尹琼 on 2023/2/24.
//

import UIKit
import FirebaseAnalytics


open class FireBaseManager: NSObject {
    
    public static let shared: FireBaseManager = FireBaseManager()
    
    
    public func setUserProperty(userProperty: FireBaseUserProperty) {
        
        if userProperty.type == .user_id {
            Analytics.setUserID(userProperty.value)
            return
        }
        
        Analytics.setUserProperty(userProperty.value, forName: userProperty.type.name)
   
    }
    
    public func logEvent(event: FireBaseEvent) {

        Analytics.logEvent(event.select.name, parameters: event.itemNameType.paramters)
        
    }
    
    public func logScreenView(screenName: FireBaseScreenNameType, screenClass: UIViewController) {
        
        Analytics.logEvent(AnalyticsEventScreenView,
                           parameters: [AnalyticsParameterScreenName: screenName.name,
                                       AnalyticsParameterScreenClass: "\(screenClass.classForCoder)"])
        
    }
    
    
}
